Puppet - How to Use [facter variables]
2014/01/26 |
Facter variables which are the system settings are set automatically,
It's possible to use them if need.
|
|
[1] | Display facter variables. |
[root@dlp ~]# facter architecture => x86_64 augeasversion => 1.0.0 bios_release_date => 01/01/2007 bios_vendor => Seabios bios_version => 0.5.1 blockdevice_vda_size => 21474836480 blockdevice_vda_vendor => 6900 ... ... ... uptime_hours => 4 uptime_seconds => 14460 uuid => D18358C8-192C-E194-85F7-F8D46D1DBA68 virtual => kvm |
[2] | For example, if OS is "RedHat" or "CentOS" and version is "6.5", apply "sample01" class, if version is not "6.5", apply "sample02" class, if OS is not "RedHat" or "CentOS", apply "sample03" class. |
[root@dlp ~]#
vi /etc/puppet/manifests/site.pp class sample01 { file { '/home/testfile.txt': ensure => file, owner => 'root', group => 'root', mode => 644, content => 'This is the puppet test file.', } } class sample02 { user { 'cent': ensure => present, home => '/home/cent', managehome => true, password => '$6$0XTc2rjlxxxxxxxx', } } class sample03 { file { '/home/testfile2.txt': ensure => file, owner => 'root', group => 'wheel', content => 'test file2', } } case $operatingsystem { 'RedHat', 'CentOS': { if $operatingsystemrelease == '6.5' { include 'sample01' } else { include 'sample02' } } default: { include 'sample03' } } |